<?php
session_start();
?>
<html>
	<head>		
		<link rel="stylesheet" type="text/css" href="css/maquetado.css"/>
		<link rel="stylesheet" type="text/css" href="css/styleFijo.css"/>			
		<link rel="stylesheet" type="text/css" href="facebox/facebox.css" />
		<link rel="stylesheet" type="text/css" href="css/admin.css" />	
		
		<script src="js/jquery-1.9.1.min.js" type="text/javascript"></script>
		<script src="js/cookies.js" type="text/javascript"></script>
		<script src="js/estiloAdmin.js" type="text/javascript"></script>
		<script src="js/adminDatos.js" type="text/javascript"></script>
	</head>
	<body> 
		
		<?php
		include('handler_bd.php');
		if (!(isset($_SESSION['username']))) {?>
		<div id="login-outer-center">
			<div id="login-inner-center">
				<form  action="checklogin.php" method="post">
					<table class="tablaCentrada">
						<tr>
							<td>Username:</td>
							<td><input type="text" name="user" id="user" width="100"></td>
						</tr>
						<tr>
							<td>Password: </td>
							<td><input type="password" name="pass" id="pass"></td>
						</tr>					
						<tr>
							<td></td>
							<td>
								<div align="right">
									<input type="submit" value="Login" />
								</div>
							</td>
						</tr>						
					</table>
				</form>
				<?php if(isset($_GET['fail'])){ ?>
						<div id="loginFail">Usuario o contraseña incorrectos. Intente de nuevo.</div>						
						<?php } ?>
			</div>
		</div>
		<?php } else {  ?>
		<form action="logout.php" style="margin-bottom: 0"><input class="botfav" type="submit" value="Logout"/></form>		
		<h3 align="center" style="margin-top: 0">Preferencias</h3>
			
		<div>
			<form action="configuracion.php" method="post">
				<div class="admin">
				<?php 
					$result = $conn->query("SELECT clave as Clase,valor as Visible FROM Configuracion WHERE tipo='display'");
					foreach($result as $row) {
						if ($row['Visible']=='true'){
				?>
					<input type="checkbox" name="<?php echo "$row[Clase]";?>" value="<?php echo "$row[Visible]";?>" checked="checked"><?php echo ucfirst(subStr($row['Clase'],3));?><br>
				<?php }else{ ?>
					<input type="checkbox" name="<?php echo "$row[Clase]";?>" value="<?php echo "$row[Visible]";?>"><?php echo ucfirst(subStr($row['Clase'],3));?><br>
                <?php } } ?>
                </div>
                <div class="pag">
                	Propiedades por pagina:
                	<input type="text" name="inputPaginas" size="4" value="1"/>                	                	
                </div>               
			
			</form>
			 <div align="center" style="margin-top:-130px">
                	<form action="backup.php">
                		<input class="botfav" type="submit" value="Descargar Backup" />	
                	</form>
                	<a  target="_blank" href="admin"><button class="botfav" id="adminDat">Administrar Datos</button></a>
             </div>
             	<div align="center">
					<input class="botfav" type="submit" value="Aceptar" />					
				</div>
		</div>
		<?php } ?>
	</body>
	
</html>